package ai.plantdata.FrontControllerPattern.controller;

import ai.plantdata.FrontControllerPattern.dispatcher.Dispatcher;

/**
 * @Author: WangHui
 * @Date: 2020/12/24 16:08
 * @Description:
 */
public class FrontController {
    private Dispatcher dispatcher;

    public FrontController() {
        this.dispatcher = new Dispatcher();
    }

    private boolean isAuthenticUser(){
        System.out.println("User id authenticated successfully.");
        return true;
    }

    private void trackRequest(String request){
        System.out.println("Page request: " + request);
    }

    public void dispatcherRequest(String request){
        trackRequest(request);
        if(isAuthenticUser()){
            dispatcher.dispatch(request);
        }
    }

}
